
<div id="content">
    <div smart-include="sensor/views/sub-header.tpl.html"></div>
    <div class="clearfix margin-bottom-10">
        <div class="pull-left margin-right-20">
            <a class="btn btn-labeled btn-primary" data-toggle="modal" data-target="#addAlert"> <span class="btn-label"><i class="glyphicon glyphicon-plus"></i></span>添加参数设置</a>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover no-margin font-sml table-striped sensor_table">
            <thead>
                <tr>
                    <th>操作</th>
                    <th class="text-align-center">端口号</th>
                    <th class="text-align-center">参数类型</th>
                    <th class="text-align-center">key</th>
                    <th class="text-align-center">value</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="data in datas">
                    <td>
                        <button class='btn btn-xs btn-default' uib-tooltip='编辑' tooltip-append-to-body='true' ng-click="showEditAlert(data)"><i class='fa fa-pencil'></i></button>
                        <button class='btn btn-xs btn-default' uib-tooltip='删除' tooltip-append-to-body='true' ng-click="showDelDialog(data.id,data.key1)"><i class='fa fa-times'></i></button>
                    </td>
                    <td class="text-align-center">
                            {{data.pro_type}}
                    </td>
                    <td class="text-align-center">
                            {{data.typename}}
                    </td>
                    <td class="text-align-center">{{data.key1}}</td>
                    <td class="text-align-center">{{data.value1}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- end widget content -->
    <div class="dt-toolbar-footer">
        <tm-pagination conf="paginationConf"></tm-pagination>
    </div>

    <div class="modal fade" id="addAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">添加参数设置</h4>
                </div>
                <div class="modal-body">
                    <form id="smart-form-register" class="smart-form" data-smart-registration-form ng-submit="insertdata()">
                        <fieldset class="row" style="padding-top: 5px;">
                             <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">端口</label>
                                <label class="select">
                                    <select required="required" ng-model="insert.pro_type" ng-change="port_change(insert.pro_type)">
                                        <option value="{{ty.port}}" ng-repeat = "ty in ports">{{ty.port}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                             </section>
                             <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">参数类型</label>       
                                <label class="select">
                                    <select class="form-control" ng-model="insert.type" ng-change="par_change(insert.type)">
                                        <option ng-repeat="t in par_types" value="{{t.id}}">{{t.name}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label> 
                            </section>                            
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-show="parshow">
                                <label class="label">参数(key)</label>
                                <label class="input">
                                    <input class="form-control" ng-model="insert.key1" />
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-hide="parshow">
                                <label class="label">参数(key)</label>
                                <label class="input">
                                    <select class="form-control" ng-model="insert.key1" >
                                        <option ng-repeat="t in par_column" value="{{t.COLUMN_NAME}}">{{t.COLUMN_NAME}}</option>
                                    </select>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">参数(value)</label>
                                <label class="input">
                                    <input class="form-control" ng-model="insert.value1"/>
                                    <span style="color: red; position: absolute; top: 0; right: -10px">*</span>
                                </label>
                            </section>
                        </fieldset>
                        <footer>
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>

                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="editAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">编辑警告设置</h4>
                </div>
                <div class="modal-body">
                    <form id="smart-form-register" class="smart-form" data-smart-registration-form ng-submit="updatedata()">
                        <fieldset class="row" style="padding-top: 5px;">
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">端口号</label>
                                <label class="select">
                                    <select required="required" ng-model="editdata.pro_type">
                                        <option value="{{ty.port}}" ng-repeat = "ty in ports">{{ty.port}}</option>
                                    </select>
                                </label>
                             </section>
                             <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">参数类型</label>       
                                <label class="select">
                                    <select class="form-control" ng-model="editdata.type" >
                                        <option ng-repeat="t in par_types" value="{{t.id}}">{{t.name}}</option>
                                    </select>
                                </label> 
                            </section>                            
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">参数(key)</label>
                                <label class="input">
                                    <input class="form-control" ng-model="editdata.key1"></input>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">参数(value)</label>
                                <label class="input">
                                    <input class="form-control" ng-model="editdata.value1"></input>
                                </label>
                            </section>
                        </fieldset>
                        <footer>
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>
                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="showDelDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title">信息</h4>
                </div>
                <div class="modal-body">
                    <p>
                        您确实要删除这个参数设置吗？
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" ng-click="deldevice()">
                        删除
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
    <!-- /.modal-dialog -->
</div>
 <!-- END MAIN CONTENT -->